﻿using FluentNHibernate.Mapping;
using nsadv.Statistic.Domain;

namespace nsadv.Statistic.Repository.NHibernate.Config.Maps
{
	internal class CampaignMap : ClassMap<Campaign>
	{
		public CampaignMap()
		{
			Table("Campaigns");
			Id(x => x.Id)
				.Length(50);//
				//.GeneratedBy.Custom<Utils.IdentifierGenerator>();
			Map(x => x.Name);
			Map(x => x.StartTime)
				.Nullable();
			Map(x => x.EndTime)
				.Nullable();
			Map(x => x.IsActive);
			References<Advertiser>(x => x.Advertiser)
				.Column("AdvertiserId")
				.Not.LazyLoad();
			HasMany<Banner>(x => x.Banners)
				.KeyColumn("BannerId")
				.Cascade.All()
				.LazyLoad()
				.Inverse()
				.AsBag();
		}
	}
}
